//
//  NRWCarDetailNameCell.m
//  NRWMall
//
//  Created by 张记 on 2018/5/22.
//  Copyright © 2018年 com.anpxd. All rights reserved.
//

#import "NRWCarDetailNameCell.h"
#import "NRWCarPopTool.h"
#import "AppDelegate+ui.h"

@interface NRWCarDetailNameCell ()
@property (weak, nonatomic) IBOutlet UILabel *nameL;
@property (weak, nonatomic) IBOutlet UILabel *priceL;
@property (weak, nonatomic) IBOutlet UILabel *OtherL;
@property (weak, nonatomic) IBOutlet UIButton *enquireB;

@end

@implementation NRWCarDetailNameCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.enquireB.layer.cornerRadius = 15;
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginSuccessful:) name:userLoginSuccess object:nil];

}
- (IBAction)enquirePriceFor:(id)sender {
//    self.enquirePriceBlock();
    if ([NRWUserInfoModel shared].isLogin == YES) {
        [NRWCarPopTool popUpWithController:[[AppDelegate shareAppDelegate] getCurrentUIVC] type:PopType_InputPhone carModel:_carModel success:^(id info) {
            
        }];
      
    }else{
        NRWLoginView *loginView = [[NRWLoginView alloc] init];
        loginView.type = kAskingPrice;
        [loginView show];
    }
  
}
-(void)loginSuccessful:(NSNotification *)nofit{
    if ([nofit.object isEqualToString:kAskingPrice]) {
        [NRWCarPopTool popUpWithController:[[AppDelegate shareAppDelegate] getCurrentUIVC] type:PopType_InputPhone carModel:_carModel success:^(id info) {
            
        }];
        
    }
    
}
-(void)setCarModel:(CarResult *)carModel{
    _carModel = carModel;
    self.nameL.text = carModel.carTitle;
    self.priceL.text = carModel.priceStr;
    NSString *transfer = @"不含过户费";
    if ( carModel.carTransferState == 1) {
        transfer = @"包含过户费";
    }
    NSString *oneOrice = @"不是一口价";
    if (carModel.carFixedPriceState == 1) {
        oneOrice = @"是一口价";
    }
    self.OtherL.text = [NSString stringWithFormat:@"%@ | %@",transfer,oneOrice];
    
}
@end
